package com.guslegend.Class01_ioc.test;

import com.guslegend.Class01_ioc.HappyPlay;
import com.guslegend.Class01_ioc.HappyTime;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author: guslegend
 * @description: Bean 属性赋值：内部Bean声明
 * @create: 2025-04-27 10:22
 **/
public class InBean {

    @Test
    public void testIn(){
        ApplicationContext iocContainer=
                new ClassPathXmlApplicationContext("bean1.xml");

        HappyPlay happyPlay=iocContainer.getBean("happyPlay3" , HappyPlay.class);

        //通过外部bean,可以获取专属内部bean
        System.out.println(happyPlay.getHappyTime().getTime());

        //直接获取内部bean,输出! [[报错]]
        HappyTime happyTime=iocContainer.getBean(HappyTime.class);
        System.out.println("happyTime ="+happyTime);
    }
}
